<?php 
	$data['menu'] = 'module';
	$data['title'] = '产品类型';
	$data['site_url'] = site_url('manager/goods/type/');
	$this->load->view('manager/header',$data);
?>
<div class="crumbs">当前位置：<a href="#">模块管理</a> &gt; <a href="#">产品设置管理</a> &gt; <span class="silver">产品类型</span></div>
<div class="tip tip-b">
    <p class="alert noclose"><i class="icon"></i>产品类型：可提供列表选择搜索。<a class="steelBlue" href="#"></a></p>				
</div>
<div class="list-tab">
	<ul>
		<li <?php if($action == 'list') echo 'class="cur"'?>><a href="<?php echo site_url('manager/goods/type/index/');?>">产品类型列表</a></li>
		<li <?php if($action == 'add') echo 'class="cur"'?> title="新增产品类型"><a href="<?php echo site_url('manager/goods/type/add/');?>" title="新增产品类型">新增产品类型</a></li>
		<?php if($action == 'edit') 
			echo '<li class="cur" title="编辑产品类型">编辑产品类型</li>';
		?>
	</ul>
</div>
<?php if($action == 'list'){?>
<table class="list-table list-table-s">
	<thead>
		<tr class="th-extra">
			<th align="center"><input id="checkall" type="checkbox"/></th>
			<th colspan="3" align="left">
				<label for="checkall" class="checkall-label">全选</label><span class="divide"></span><a href="#">删除</a>
			</th>
		</tr>
		<tr>
			<th align="center" width="20"></th>
			<th align="left">名称</th>
			<th align="left" width="100">别名</th>
			<th align="left" width="200">操作</th>
		</tr>
	</thead>
	<tbody>
		<?php if(isset($list) && count($list))
			foreach ($list as $item) {
		?>
		<tr>
			<td align="center" width="20"></td>
			<td align="left"><?php echo $item['name']?></td>
			<td align="left" width="100"><?php echo $item['alias']?></td>
			<td align="left" width="200"><a href="<?php echo site_url('manager/goods/type/edit/'),'/',$item['id'];?>">编辑</a> / <a class="op_ajax" href="<?php echo site_url('manager/goods/type/dodelete/'.$item['id'])?>">删除</a></td>
		</tr>
		<?php }else{?>	
		<tr>
			<td colspan="4" align="center">	
				<div class="med-tip">
					<p class="attention noclose noborder nobackground">
						<i class="icon"></i>
						对不起，暂无数据！
					</p>
				</div>
			</td>
		</tr>
		<?php }?>
	</tbody>
</table>
<?php $this->load->view('pager');?>
<?php }else if($action == 'add' || $action == 'edit'){?>
<form action="<?php echo site_url('manager/goods/type/do'.$action.'/');?>" method="post">
	<table class="list-table list-table-s form5">
		<thead>
			<tr>
				<th colspan="4" align="left" height="35">
					<span class="red">* </span>名称：<input name="type[name]" type="text" value="<?php if(isset($type)) echo $type['name']?>"/>
				</th>
			</tr>
			<tr>
				<th colspan="4" align="left" height="35">
					&nbsp;&nbsp; 别名：<input name="type[alias]" type="text" value="<?php if(isset($type)) echo $type['alias']?>"/>
				</th>
			</tr>
			<tr>
				<th align="left" width="70">属性名称</th>
				<th align="left" width="100">属性展示方式</th>
				<th align="left">属性值</th>
				<th align="center" width="100">操作</th>
			</tr>
		</thead>
		<tbody>
		<?php 
			$hasType = isset($type);
//			$num = $hasType?count($type):0;
			for ($i = 0; $i < 9; $i++) {
//				$hasType = $hasType && $i < $num;
		?>
			<tr>
				<td align="left" width="70"><input type="text" name="type[attr][<?php echo $i?>][k]" value="<?php if($hasType) echo $type['attr'][$i]['k']?>"/></td>
				<td align="left" width="100">
					<select name="type[attr][<?php echo $i?>][t]">
						<option value="1" <?php if($hasType && $type['attr'][$i]['t']==1) echo "selected"?>>下拉选择式</option>
						<option value="2" <?php if($hasType && $type['attr'][$i]['t']==2) echo "selected"?>>内容填充式</option>
					</select>
				</td>
				<td align="left"><input type="text" size="80" name="type[attr][<?php echo $i?>][v]" value="<?php if($hasType) echo $type['attr'][$i]['v']?>"/></td>
				<td align="center" width="100"><a>删除</a></td>
			</tr>
		<?php }?>
		</tbody>
		<tfoot>
			<tr>
				<th colspan="4" align="center" height="35">
					<?php if($hasType) echo "<input type=hidden name=type[id] value=".$type['id']." />"?>
					<input class="op_ajax_s" type="submit" value="提交"/>
				</th>
			</tr>
		</tfoot>
	</table>
</form>
<?php }?>
<?php $this->load->view('manager/footer');?>